package com.neuedu.my12306;

import com.neuedu.my12306.my.MyAccountActivity;
import com.neuedu.my12306.my.MyContactActivity;
import com.neuedu.my12306.my.MyPasswordActivity;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class MainActivity extends Activity {
	Button btnContact = null;
	Button btnAccount = null;
	Button btnPassword = null;
	Button btnLogout = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// 设置全屏模式
		// getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
		// 去除标题行
		// requestWindowFeature(Window.FEATURE_NO_TITLE);

		setContentView(R.layout.activity_main);

		// System.out.println("---onCreate---");
		Log.d("My12306", "---onCreate---");

		btnContact = (Button) findViewById(R.id.btnContact);
		btnAccount = (Button) findViewById(R.id.btnAccount);
		btnPassword = (Button) findViewById(R.id.btnPassword);
		btnLogout = (Button) findViewById(R.id.btnLogout);

		MyButtonListener listener = new MyButtonListener();
		btnContact.setOnClickListener(listener);
		btnAccount.setOnClickListener(listener);
		btnPassword.setOnClickListener(listener);
		btnLogout.setOnClickListener(listener);

	}

	class MyButtonListener implements OnClickListener {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			// 区分按钮
			Intent intent = new Intent();

			switch (v.getId()) {
				case R.id.btnContact:
					intent.setClass(MainActivity.this, MyContactActivity.class);
					startActivity(intent);
					break;
				case R.id.btnAccount:
					intent.setClass(MainActivity.this, MyAccountActivity.class);
					startActivity(intent);
					break;
				case R.id.btnPassword:
					intent.setClass(MainActivity.this, MyPasswordActivity.class);
					startActivity(intent);
					break;
				case R.id.btnLogout:
					intent.setClass(MainActivity.this, LoginActivity.class);
					startActivity(intent);
					finish();
					break;
			}

		}

	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		Log.d("My12306", "---onStart---");
	}

	@Override
	protected void onRestart() {
		// TODO Auto-generated method stub
		super.onRestart();
		Log.d("My12306", "---onRestart---");
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		Log.d("My12306", "---onPause---");
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Log.d("My12306", "---onResume---");
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
		Log.d("My12306", "---onStop---");
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		Log.d("My12306", "---onDestroy---");
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		// TODO Auto-generated method stub
		super.onSaveInstanceState(outState);
		Log.d("My12306", "---onSaveInstanceState---");
	}

	@Override
	protected void onRestoreInstanceState(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onRestoreInstanceState(savedInstanceState);
		Log.d("My12306", "---onRestoreInstanceState---");
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
